package apps.controlador;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

import org.primefaces.model.menu.DefaultMenuItem;
import org.primefaces.model.menu.DefaultMenuModel;
import org.primefaces.model.menu.DefaultSubMenu;
import org.primefaces.model.menu.MenuModel;

@ManagedBean
//@RequestScoped
public class menuBean {
	
private MenuModel model; 

public menuBean(){
	model=new DefaultMenuModel();
	//first submenu
	DefaultSubMenu firstsubmenu =new DefaultSubMenu("Admistrador");
	DefaultMenuItem item=new DefaultMenuItem("Crear Entidad");
	item.setUrl("/public/crear-entidad.jsf");
	
	DefaultMenuItem item2=new DefaultMenuItem("Listar Entidades");
	item2.setUrl("/public/listar.jsf");
	
	firstsubmenu.addElement(item);
	firstsubmenu.addElement(item2);
	model.addElement(firstsubmenu);
	
}
	public MenuModel getModel(){
		return model;
	}
	
	public String redirect() {  
        return "home?faces-redirect=true";  
    }  
      
    public void addMessage(String summary) {  
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary,  null);  
        FacesContext.getCurrentInstance().addMessage(null, message);  
    }  

}

